Device model SXP cleanup
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Mon, 11 Jul 2005 20:09:10 +0000 (20:09 +0000)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Mon, 11 Jul 2005 20:09:10 +0000 (20:09 +0000)
- don't pollute the sxp with unused options
- use the same syntax as paravirtualized domains for disks

Signed-off-by: Edwin Zhai <edwin.zhai@intel.com>
Signed-off-by: Arun Sharma <arun.sharma@intel.com>
tools/examples/xmexample.vmx
tools/python/xen/xend/image.py
tools/python/xen/xm/create.py

index ac144592251e19b5c55e9ff3cb87c0b697eb6d70..1c85a02d4ccd84f5d183bdb6ff78cccb939648e9 100644 (file)
@@ -46,6 +46,7 @@ nics=0
 # and MODE is r for read-only, w for read-write.
 
 #disk = [ 'phy:hda1,hda1,r' ]
+disk = [ 'file:/var/images/min-el3-i386.img,hda,w' ]
 
 #----------------------------------------------------------------------------
 # Set the kernel command line for the new domain.
@@ -96,10 +97,6 @@ memmap = '/usr/lib/xen/boot/mem-map.sxp'
 
 #-----------------------------------------------------------------------------
 # Disk image for 
-hda='/var/images/min-el3-i386.img'
-#hdb=
-#hdc=
-#hdd=
 #cdrom=
 
 #-----------------------------------------------------------------------------
index aed0f95435e6de5cff63ff1fd5b8811a4885c02d..8c8f2027b41eb3d7b0847f54129977274c697859 100644 (file)
@@ -265,7 +265,7 @@ class VmxImageHandler(ImageHandler):
     # Return a list of cmd line args to the device models based on the
     # xm config file
     def parseDeviceModelArgs(self):
-       dmargs = [ 'hda', 'hdb', 'hdc', 'hdd', 'cdrom', 'boot', 'fda', 'fdb',
+       dmargs = [ 'cdrom', 'boot', 'fda', 'fdb',
                    'localtime', 'serial', 'macaddr', 'stdvga', 'isa' ] 
        ret = []
        for a in dmargs:
@@ -276,17 +276,31 @@ class VmxImageHandler(ImageHandler):
 
             # Handle booleans gracefully
             if a in ['localtime', 'std-vga', 'isa']:
-                v = int(v)
+                if v != None: v = int(v)
 
            log.debug("args: %s, val: %s" % (a,v))
            if v: 
                ret.append("-%s" % a)
                ret.append("%s" % v)
 
+        # Handle hd img related options
+        device = sxp.child(self.vm.config, 'device')
+        vbdinfo = sxp.child(device, 'vbd')
+        if not vbdinfo:
+            raise VmError("vmx: missing vbd configuration")
+        uname = sxp.child_value(vbdinfo, 'uname')
+        vbddev = sxp.child_value(vbdinfo, 'dev')
+        (vbdtype, vbdparam) = string.split(uname, ':', 1)
+        vbddev_list = ['hda', 'hdb', 'hdc', 'hdd']
+        if vbdtype != 'file' or vbddev not in vbddev_list:
+            raise VmError("vmx: for qemu vbd type=file&dev=hda~hdd")
+        ret.append("-%s" % vbddev)
+        ret.append("%s" % vbdparam)
+
        # Handle graphics library related options
-       vnc = int(sxp.child_value(self.vm.config, 'vnc'))
-       sdl = int(sxp.child_value(self.vm.config, 'sdl'))
-       nographic = int(sxp.child_value(self.vm.config, 'nographic'))
+       vnc = sxp.child_value(self.vm.config, 'vnc')
+       sdl = sxp.child_value(self.vm.config, 'sdl')
+       nographic = sxp.child_value(self.vm.config, 'nographic')
        if nographic:
            ret.append('-nographic')
            return ret
index 7af150f7908db665768e8b8d96faf3d870b1a910..2b86d036764685164164b317bd59785b55f2ea5b 100644 (file)
@@ -254,22 +254,6 @@ gopts.var('device_model', val='FILE',
           fn=set_value, default='',
           use="Path to device model program.")
 
-gopts.var('hda', val='FILE',
-          fn=set_value, default='',
-          use="Path to hda")
-
-gopts.var('hdb', val='FILE',
-          fn=set_value, default='',
-          use="Path to hdb")
-
-gopts.var('hdc', val='FILE',
-          fn=set_value, default='',
-          use="Path to hdc")
-
-gopts.var('hdd', val='FILE',
-          fn=set_value, default='',
-          use="Path to hdd")
-
 gopts.var('fda', val='FILE',
           fn=set_value, default='',
           use="Path to fda")
@@ -442,11 +426,12 @@ def configure_vfr(opts, config, vals):
 def configure_vmx(opts, config_devs, vals):
     """Create the config for VMX devices.
     """
-    args = [ 'memmap', 'device_model', 'hda', 'hdb', 'hdc', 'hdd', 'cdrom',
+    args = [ 'memmap', 'device_model', 'cdrom',
             'boot', 'fda', 'fdb', 'localtime', 'serial', 'macaddr', 'stdvga', 
-             'isa', 'nographic', 'vnc', 'sdl', 'display']       
+             'isa', 'nographic', 'vnc', 'sdl', 'display']        
     for a in args:
-       config_devs.append([a, vals.__dict__[a]])
+       if (vals.__dict__[a]):
+           config_devs.append([a, vals.__dict__[a]])
 
 def run_bootloader(opts, config, vals):
     if not os.access(vals.bootloader, os.X_OK):
@@ -604,7 +589,7 @@ def preprocess_vnc(opts, vals):
     """If vnc was specified, spawn a vncviewer in listen mode
     and pass its address to the domain on the kernel command line.
     """
-    if not vals.vnc: return
+    if not vals.vnc or vals.dryrun: return
     vnc_display = choose_vnc_display()
     if not vnc_display:
         opts.warn("No free vnc display")
@@ -678,8 +663,6 @@ def main(argv):
         config = opts.vals.config
     else:
         opts.load_defconfig()
-        if opts.vals.dryrun:
-           opts.vals.vnc = 0
         preprocess(opts, opts.vals)
         if not opts.getopt('name') and opts.getopt('defconfig'):
             opts.setopt('name', os.path.basename(opts.getopt('defconfig')))